<?php
/**
 * Created by PhpStorm.
 * User: Mak
 * Date: 2016/3/12
 * Time: 15:50
 */

namespace Home\Controller;
use Think\Controller;

class UserInfoController extends Controller{

    public function _initialize(){
        header("content-type:text/html; charset=utf-8");
        $flag = session("?username");
        if(!$flag){
            $this->error("未登录",U('Login/index'));
        }
    }

    public function index(){
        $username=session("username");

        $stuenroll=M("stuenroll");

        $UserInfo=$stuenroll->where("stuid={$username}")->select();

        $this->assign("UserInfo",$UserInfo);
        $this->display();
    }

    public function remove(){
        $data["stuid"]=session("username");
        $data["enroll"]=I("enroll");

        $stuenroll=M("stuenroll");

        if($stuenroll->where($data)->delete()){
            $this->success("取消成功");
        }else{
            $this->error("取消失败");
        }
    }
}